System Control Unit(SCU) driver for XMC microcontroller family.
More...
System Control Unit(SCU) driver for XMC microcontroller family.
System control unit is the SoC power, reset and a clock manager with additional responsibility of providing system stability protection and other auxiliary functions.
SCU provides the following features,
- Power control
- Reset control
- Clock control
- Miscellaneous control(boot mode, system interrupts etc.)
The SCU driver is divided in to clock control logic, reset control logic, system interrupt control logic and miscellaneous control logic.
Clock driver features:
- Allows clock configuration using the structure XMC_SCU_CLOCK_CONFIG_t and API XMC_SCU_CLOCK_Init()
Reset driver features:
Interrupt driver features:
- Provides APIs for enabling/ disabling interrupt event generation XMC_SCU_INTERRUPT_EnableEvent(), XMC_SCU_INTERRUPT_DisableEvent()
- Provides API for registering callback function for events XMC_SCU_INTERRUPT_SetEventHandler()
Miscellaneous features:
- Allows to trigger multiple capture compare unit(CCU) channels to be started together XMC_SCU_SetCcuTriggerHigh()
◆ XMC_SCU_INTERRUPT_EVENT_HANDLER_t
| typedef void(* XMC_SCU_INTERRUPT_EVENT_HANDLER_t) (void) |
Function pointer type used for registering callback functions on SCU event occurrence.
Definition at line 187 of file xmc_scu.h.
◆ XMC_SCU_STATUS_t
Defines the status of SCU API execution, used to verify the SCU related API calls.
◆ XMC_SCU_STATUS
Defines the status of SCU API execution, used to verify the SCU related API calls.
| Enumerator |
|---|
| XMC_SCU_STATUS_OK | SCU related operation successfully completed.
|
| XMC_SCU_STATUS_ERROR | SCU related operation failed. When API cannot fulfill request, this value is returned.
|
| XMC_SCU_STATUS_BUSY | Cannot execute the SCU related operation request because another operation is in progress. XMC_SCU_STATUS_BUSY is returned when API is busy processing another request.
|
Definition at line 170 of file xmc_scu.h.
◆ XMC_SCU_CLOCK_GatePeripheralClock()
| void XMC_SCU_CLOCK_GatePeripheralClock |
( |
const XMC_SCU_PERIPHERAL_CLOCK_t |
peripheral | ) |
|
◆ XMC_SCU_CLOCK_GetCpuClockFrequency()
- Returns
- uint32_t Value of CPU clock frequency.
- Description
- Provides the vlaue of CPU clock frequency.
The value is stored in a global variable SystemCoreClock. It is updated when the clock configuration is done using the SCU LLD APIs. The value represents the frequency of clock used for CPU operation. Range: Value is of type uint32_t, and gives the value of frequency in Hertz.
- Related APIs:
- XMC_SCU_CLOCK_GetPeripheralClockFrequency(), XMC_SCU_CLOCK_GatePeripheralClock()
Definition at line 425 of file xmc_scu.h.
◆ XMC_SCU_CLOCK_GetPeripheralClockFrequency()
| uint32_t XMC_SCU_CLOCK_GetPeripheralClockFrequency |
( |
void |
| ) |
|
◆ XMC_SCU_CLOCK_Init()
| void XMC_SCU_CLOCK_Init |
( |
const XMC_SCU_CLOCK_CONFIG_t *const |
config | ) |
|
◆ XMC_SCU_CLOCK_IsPeripheralClockGated()
| bool XMC_SCU_CLOCK_IsPeripheralClockGated |
( |
const XMC_SCU_PERIPHERAL_CLOCK_t |
peripheral | ) |
|
◆ XMC_SCU_CLOCK_UngatePeripheralClock()
| void XMC_SCU_CLOCK_UngatePeripheralClock |
( |
const XMC_SCU_PERIPHERAL_CLOCK_t |
peripheral | ) |
|
◆ XMC_SCU_GetMirrorStatus()
- Returns
- uint32_t Status of the register mirror update.
Range: Use the bit mask of the SCU_GENERAL_MIRRSTS register for the mirror update event of interest. e.g.: SCU_GENERAL_MIRRSTS_RTC_CTR_Msk. Multiple update events can be combined using OR operation.
- Description
- Provides the status of hibernate domain register update, when the respective mirror registers are changed.
The hibernate domain is connected to the core domain via SPI serial communication. MIRRSTS is a status register representing the communication of changed value of a mirror register to its corresponding register in the hibernate domain. The bit fields of the register indicate that a corresponding register of the hibernate domain is ready to accept a write or that the communication interface is busy with executing the previous operation.
Note: There is no hibernate domain in XMC1x devices. This register is retained for legacy purpose.
Definition at line 543 of file xmc_scu.h.
Referenced by XMC_RTC_Init(), XMC_RTC_SetAlarm(), XMC_RTC_SetPrescaler(), XMC_RTC_SetTime(), XMC_RTC_Start(), and XMC_RTC_Stop().
◆ XMC_SCU_INTERRUPT_ClearEventStatus()
| void XMC_SCU_INTERRUPT_ClearEventStatus |
( |
const XMC_SCU_INTERRUPT_EVENT_t |
event | ) |
|
◆ XMC_SCU_INTERRUPT_DisableEvent()
| void XMC_SCU_INTERRUPT_DisableEvent |
( |
const XMC_SCU_INTERRUPT_EVENT_t |
event | ) |
|
- Parameters
-
| event | Bit mask of the event to disable. Range: Use type XMC_SCU_INTERRUPT_EVENT_t for providing the input value. Multiple events can be combined using the OR operation. |
- Returns
- None
- Description
- Disables generation of interrupt on occurrence of the input event.
The events are disabled by resetting the respective bit fields in the SRMSK register.
- Related APIs:
- NVIC_DisableIRQ(), XMC_SCU_INTERRUPT_EnableEvent()
Definition at line 367 of file xmc1_scu.c.
◆ XMC_SCU_INTERRUPT_EnableEvent()
| void XMC_SCU_INTERRUPT_EnableEvent |
( |
const XMC_SCU_INTERRUPT_EVENT_t |
event | ) |
|
- Parameters
-
| event | Bit mask of the event to enable. Range: Use type XMC_SCU_INTERRUPT_EVENT_t for providing the input value. Multiple events can be combined using the OR operation. |
- Returns
- None
- Description
- Enables the generation of interrupt for the input events.
The events are enabled by setting the respective bit fields in the SRMSK register.
Note: User should separately enable the NVIC node responsible for handling the SCU interrupt. The interrupt will be generated when the respective event occurs.
- Related APIs:
- NVIC_EnableIRQ(), XMC_SCU_INTERRUPT_DisableEvent()
Definition at line 358 of file xmc1_scu.c.
◆ XMC_SCU_INTERRUPT_SetEventHandler()
- Parameters
-
| event | The event for which the interrupt handler is to be configured.
Range: Use type XMC_SCU_INTERRUPT_EVENT_t for identifying the event. |
| handler | Name of the function to be executed when the event if detected.
Range: The function accepts no arguments and returns no value. |
- Returns
- XMC_SCU_STATUS_t Status of configuring the event handler function for the selected event.
Range: XMC_SCU_STATUS_OK if the event handler is successfully configured.
XMC_SCU_STATUS_ERROR if the input event is invalid.
- Description
- Assigns the event handler function to be executed on occurrence of the selected event.
If the input event is valid, the handler function will be assigned to a table to be executed when the interrupt is generated and the event status is set in the event status register. By using this API, polling for a particular event can be avoided. This way the CPU utilization will be optimized. Multiple SCU events can generate a common interrupt. When the interrupt is generated, a common interrupt service routine is executed. It checks for status flags of events which can generate the interrupt. The handler function will be executed if the event flag is set.
- Related APIs:
- XMC_SCU_INTERRUPT_TriggerEvent(), XMC_SCU_INTERUPT_GetEventStatus()
Definition at line 828 of file xmc1_scu.c.
◆ XMC_SCU_INTERRUPT_TriggerEvent()
| void XMC_SCU_INTERRUPT_TriggerEvent |
( |
const XMC_SCU_INTERRUPT_EVENT_t |
event | ) |
|
- Parameters
-
| event | Bit mask of the event to be triggered. Range: Use type XMC_SCU_INTERRUPT_EVENT_t for providing the input value. Multiple events can be combined using the OR operation. |
- Returns
- None
- Description
- Triggers the event as if the hardware raised it.
Event will be triggered by setting the respective bitfield in the SRSET register.
Note: User should enable the NVIC node that handles the respective event for interrupt generation.
- Related APIs:
- NVIC_EnableIRQ(), XMC_SCU_INTERUPT_GetEventStatus(), XMC_SCU_INTERRUPT_ClearEventStatus()
Definition at line 376 of file xmc1_scu.c.
◆ XMC_SCU_INTERUPT_GetEventStatus()
| XMC_SCU_INTERRUPT_EVENT_t XMC_SCU_INTERUPT_GetEventStatus |
( |
void |
| ) |
|
- Returns
- uint32_t Status of the SCU events.
- Description
- Provides the status of all SCU events.
The status is read from the SRRAW register. To check the status of a particular event, the returned value should be masked with the bit mask of the event. The bitmask of events can be obtained using the type XMC_SCU_INTERRUPT_EVENT_t. Multiple events' status can be checked by combining the bit masks using OR operation. After detecting the event, the event status should be cleared using software to detect the event again.
- Related APIs:
- XMC_SCU_INTERRUPT_ClearEventStatus(), XMC_SCU_INTERRUPT_TriggerEvent(), XMC_SCU_INTERRUPT_SetEventHandler()
Definition at line 385 of file xmc1_scu.c.
◆ XMC_SCU_IRQHandler()
| void XMC_SCU_IRQHandler |
( |
uint32_t |
sr_num | ) |
|
- Parameters
-
| sr_num | Service request number identifying the SCU interrupt generated.
Range: 0 to 2. XMC4x devices have one common SCU interrupt, so the value should be 0.
But XMC1x devices support 3 interrupt nodes. |
- Returns
- None
- Description
- A common function to execute callback functions for multiple events.
It checks for the status of events which can generate the interrupt with the selected service request. If the event is set, the corresponding callback function will be executed. It also clears the event status bit.
Note: This is an internal function. It should not be called by the user application.
- Related APIs:
- XMC_SCU_INTERRUPT_SetEventHandler()
Definition at line 859 of file xmc1_scu.c.
◆ XMC_SCU_RESET_ClearDeviceResetReason()
- Returns
- None
- Description
- Clears the reset reason bits in the reset status register.
Clearing of the reset status information in the SCU_RSTSTAT register via register bit RSTCLR.RSCLR is strongly recommended to ensure a clear indication of the cause of next reset.
- Related APIs:
- XMC_SCU_RESET_GetDeviceResetReason()
Definition at line 406 of file xmc_scu.h.
◆ XMC_SCU_RESET_GetDeviceResetReason()
- Returns
- uint32_t Status representing the reason for device reset.
- Description
- Provides the value representing the reason for device reset.
The return value is an encoded word, which can indicate multiple reasons for the last reset. Each bit position of the returned word is representative of a last reset cause. The returned value should be appropriately masked to check the cause of reset. The cause of the last reset gets automatically stored in the SCU_RSTSTAT register. The reset status shall be reset after each startup in order to ensure consistent source indication after the next reset. Range: The type XMC_SCU_RESET_REASON_t can be used to get the bit masks of the reset cause.
- Related APIs:
- XMC_SCU_RESET_ClearDeviceResetReason()
Definition at line 391 of file xmc_scu.h.
◆ XMC_SCU_SetCcuTriggerHigh()
- Parameters
-
| trigger | CCU slices to be triggered synchronously via software. The value is a bitmask of CCU slice bits in the register CCUCON.
Range: Use type XMC_SCU_CCU_TRIGGER_t for bitmask of individual CCU slices. Multiple slices can be combined using OR operation. |
- Returns
- None
- Description
- Generates active edge(low to high) trigger for multiple CCU units at the same time.
Before executing this API, all the required CCU timers should configure external start. The edge of the start signal should be selected as active edge. The input signal for the CCU slice should be selected as SCU input. The above mentioned configurations can be made using the CCU LLD API XMC_CCU4_SLICE_StartConfig(). CCU timer slice should be started using XMC_CCU4_SLICE_StartTimer() before triggering the timer using this API.
- Related APIs:
- XMC_CCU4_SLICE_StartConfig(), XMC_CCU4_SLICE_SetInput(), XMC_SCU_SetCcuTriggerLow()
Definition at line 230 of file xmc_scu.h.
◆ XMC_SCU_SetCcuTriggerLow()
- Parameters
-
| trigger | CCU slices to be triggered synchronously via software. The value is a bitmask of CCU slice bits in the register CCUCON.
Range: Use type XMC_SCU_CCU_TRIGGER_t for bitmask of individual CCU slices. Multiple slices can be combined using OR operation. |
- Returns
- None
- Description
- Generates passive edge(high to low) trigger for multiple CCU units at the same time.
Before executing this API, all the required CCU timers should configure external start. The edge of the start signal should be selected as passive edge. The input signal for the CCU slice should be selected as SCU input. The above mentioned configurations can be made using the CCU LLD API XMC_CCU4_SLICE_StartConfig(). CCU timer slice should be started using XMC_CCU4_SLICE_StartTimer() before triggering the timer using this API.
- Related APIs:
- XMC_CCU4_SLICE_StartConfig(), XMC_CCU4_SLICE_SetInput(), XMC_SCU_SetCcuTriggerHigh()
Definition at line 255 of file xmc_scu.h.